package com.content.view.Share.Progress
{
	import com.library.core.IDisposable;
	
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class ProgressMediator extends Mediator implements IMediator, IDisposable
	{
		public static const NAME:String							= 'ProgressViewMediator';
		
		private var _view:Progress;
	
		public function ProgressMediator(viewComponent:Object=null)
		{
			super( NAME, viewComponent );
		}
		
		override public function onRegister():void
		{
			_view = new Progress();			
			ParentView.addChild( _view );	
		}
		
		override public function listNotificationInterests():Array
		{
			return [
				Progress.SHOW,
				Progress.HIDE,
				Progress.UPDATE,
				App.RESIZE_SYS
			];
		}
		
		/* Event Handler
		* ---------------------------------------------------- */
		override public function handleNotification(notification:INotification):void
		{
			var name:String = notification.getName();
			var body:Object = notification.getBody();
			
			switch ( name )
			{
				case Progress.SHOW:
					_view.Show();
					break;
				
				case Progress.HIDE:
					_view.Hide();
					break;
				
				case Progress.UPDATE:
					_view.update( body.percent );
					break;
				
				case App.RESIZE_SYS:
					var sWidth:int = body["width"];
					var sHeight:int = body["height"];
					SetLayout(sWidth, sHeight);
					break;
			}
		}
		
		private function SetLayout(sWidth:int, sHeight:int):void	{_view.SetLayout(sWidth, sHeight);}
		
		private function get ParentView():Sprite	{	return viewComponent as Sprite;		}
		public function Dispose():void{}
		
	}
}